<?php
include("../include/db.php");

$_SESSION['rpage'] = $_SERVER['REQUEST_URI']; 
if(!isset($_SESSION[$prefix."_username"])){header("location:../login/");exit;}
if ($_SESSION[$prefix."_security"] < 10){header("location:../login/?error=2"); exit;}

$year = date("Y");


if ($_SERVER['REQUEST_METHOD'] == "POST") { 
	$id			= $_POST[id];
	$name		= $_POST[name];
	$delete		= $_POST[delete];
	
if($delete == "DELETE"){

	//************************ UPDATE USERS ********************************  
	$query = mysql_query("DELETE FROM film_cat WHERE cat_id = '$id'", $db);
	//********************************************************************** 
	//************************ UPDATE USERS ********************************  
	$query = mysql_query("DELETE FROM categories WHERE cat_id = '$id'", $db);
	//********************************************************************** 

header("Location: cat_list.php?action=deleted"); exit; 
}	

//************************ UPDATE USERS ********************************  
$query = mysql_query("UPDATE categories SET cat_name='$name' WHERE cat_id = '$id'", $db);
//********************************************************************************* 
header("Location: cat_list.php?action=updated"); exit; 
}//END POST

$in_cat = (int)$_GET['id'];

$result = mysql_query("SELECT * FROM categories WHERE cat_id = '$in_cat'  ", $db);
$myrow = mysql_fetch_array($result, MYSQL_ASSOC)
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="includes/admin.css"/>
<title><?php echo $global_title;?></title>

</head>
<body>

<div id="wrap">
	<div id="page-header">
		<?php include('includes/header.php');?>

	</div>
	
	<div id="page-body">
		<div id="tabs">
			<?php $tab="main"; include('includes/header_tabs.php');?>
		</div>

		<div id="acp">
		<div class="panel">
			<span class="corners-top"><span></span></span>
				<div id="content">
				<div id="menu">
						
					<?php include('includes/menu_top.php');?>	
					<?php include('includes/menu_main.php');?>
					</div>
	
					<div id="main">
<a name="maincontent"></a>


	<h1>Edit Category</h1>

	<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" >
	<input type="hidden" name="id" value="<?php echo $in_cat;?>">
		<fieldset><legend>Edit Category</legend>

          <dl>
            <dt>Name:</dt>
            <dd><input type="text" name="name" id="name" required autofocus size="50" value="<?php echo $myrow[cat_name];?>"  /></dd>
          </dl>
          <dl>
            <dt>Delete Category:</dt>
            <dd><input type="checkbox" name="delete" value="DELETE"></dd>
          </dl>
                   
      <p class="submit-buttons"><input type="submit" class="button1" name="submit" id="submit" value="Update" /></p>
</fieldset>
    </form>	
		


    
		</div><!-- main -->
	</div><!-- content -->
<span class="corners-bottom"><span></span></span>
</div><!-- panel -->
</div><!-- acp -->

	
	<div id="page-footer">
	<?php include('includes/footer.php');?>
				</div>
</div><!-- page-body -->
</div><!-- wrap -->

</html>